<?php
class AppController extends Controller
{

	var $helpers = array ('Html', 'Text', 'Form', 'Reqtrack', 'Javascript', 'Ajax');
	var $components = array('Auth');
	var $uses = array('ReportType') ; 

	function beforeFilter()
	{
		if(isset($this->Auth))
		{
			$this->Auth->userModel = 'User';
			$this->Auth->fields = array('username' => 'u_username', 'password' => 'u_password');
			$this->Auth->loginAction = '/users/login';
			$this->Auth->loginRedirect = '/procedures';
			$this->Auth->loginError = "Identifiant ou mot de passe incorrects.";
			$this->Auth->logoutRedirect = '/';
			$this->Auth->authError = "Vous n'avez pas accès à cette page.";
			$this->Auth->autoRedirect = true;
			$this->Auth->authorize = 'controller';

//			if((empty($this->params['prefix']) || $this->params['controller'] != 'admin') && $this->action != 'login')
//			{
//				$this->Auth->allow();
//			}
		}

//		$this->set('walle', $this);
		if ($this->Auth->user() != null && $this->Session->read('id_projet') == null
			&& $this->params['controller'] != 'projects')
		{
			$this->flash('Veuillez sélectionner le projet concerné', array('controller' => 'projects', 'action'=>'choose'));
		}
		
		$report_types = $this->ReportType->find('all');
		$this->set('report_types', $report_types);
		
	}

	function isAuthorized()
	{
		return true;
	}
	

//	function beforeRender(){
//		$report_types = $this->ReportType->find();
//		$this->set('report_types', $report_types);
//	}
}
?>